import wepy from 'wepy';

export default class Home extends wepy.mixin {
  data = {
    // 轮播图数据
    switchlist: [],
    // 分类数据
    catelist: [],
    floorData: [],
  };

  config = {};

  methods = {
    goGoodList(url){
      console.log(url);
      
      wepy.navigateTo({
        url
      })
    }
  };
  // 获取轮播图数据
  async getSwitchList() {
    const { data: res } = await wepy.get('/home/swiperdata');
    if (res.meta.status !== 200) return wepy.baseToast();
    this.switchlist = res.message;
    this.$apply();
  }
  // 获取分页数据
  async getCate() {
    const { data: res } = await wepy.get('/home/catitems');
    if (res.meta.status !== 200) return wepy.baseToast();
    this.catelist = res.message;
    this.$apply();
  }
  // 获取楼层数据
  async getfloordata() {
    const { data: res } = await wepy.get('/home/floordata');

    if (res.meta.status !== 200) return wepy.baseToast();
    this.floorData = res.message;
    this.$apply();
  }
  onLoad() {
    this.getSwitchList();
    this.getCate();
    this.getfloordata();
  }
  onShow(){
    this.$parent.setTabBarBadge()
  }
}
